import { createStore, applyMiddleware } from 'redux'
import reducer from './reducer'
// import thunk from 'redux-thunk'
import createSagaMiddleware from 'redux-saga'
import todoSagas from './sagas'
const sagaMiddleware = createSagaMiddleware()
const store = createStore(
  reducer, /* preloadedState, */
  applyMiddleware(sagaMiddleware)
  // window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__()
);
sagaMiddleware.run(todoSagas)
export default store;

// store 必须是惟一的
// 只有store能改变自己的内容
// reducer必须是纯函数

// redux核心API
// createStore 创建store
// store.dispatch 传递action
// store.getState 获取store的所有数据
// store.subscribe 订阅store的改变，只要store发生改变，subscribe接受的回调函数就会执行
